package com.leyou.common.exception.controller;

import com.leyou.common.exception.domain.ExceptionResult;
import com.leyou.common.exception.domain.LyException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
/**
 * 有@ControllerAdvice注解的处理器，具有拦截异常的功能
 */
@ControllerAdvice
public class LyExceptionHandlerController {
    /**
     * 当前处理器只处理LyException
     * @return
     */
    @ExceptionHandler(LyException.class)
    public ResponseEntity<ExceptionResult> handlerLyException(LyException e){
        return ResponseEntity.status(e.getStatus()).body(new ExceptionResult(e));

    }

}
